import storage from 'good-storage'

const USER_INFO_KEY = '__userInfo__'
const SELLER_INFO_KEY = '__sellerInfo__'
const USER_TOKEN_KEY = '__userToken__'
const AUTO_TABLE_KEY = '__autoTable__'
const TABLES_KEY = '__tables__'
const HANDTABLE_KEY = '__handTable__'
const PACKAGES_KEY = '__packages__'
const ADDEDPACKAGE_KEY = '__addedPackage__'
const LOGISTICLIST_KEY = '__logisticList__'
const COMMONPACKAGE_KEY = '__commonPackage__'
const LOGOINFO_KEY = '__logoInfo__'

/* 用户详情 */
export const setUserInfoStorage = (query) => {
  storage.session.set(USER_INFO_KEY, query)
  return query
}
export const loadUserInfoStorage = () => {
  return storage.session.get(USER_INFO_KEY, [])
}

/* 卖家用户详情 */
export const setSellerInfoStorage = (query) => {
  storage.session.set(SELLER_INFO_KEY, query)
  return query
}
export const loadSellerInfoStorage = () => {
  return storage.session.get(SELLER_INFO_KEY, [])
}

/* 用户 Token */
export const setUserTokenStorage = (query) => {
  storage.session.set(USER_TOKEN_KEY, query)
  return query
}
export const loadUserTokenStorage = () => {
  return storage.session.get(USER_TOKEN_KEY, [])
}

/* 智能发包返回的数据 */
export const setAutoTableStorage = (query) => {
  storage.session.set(AUTO_TABLE_KEY, query)
  return query
}
export const loadAutoTableStorage = () => {
  return storage.session.get(AUTO_TABLE_KEY, [])
}

/* 表格发包返回的数据 */
export const setTablesStorage = (query) => {
  storage.session.set(TABLES_KEY, query)
  return query
}
export const loadTablesStorage = () => {
  return storage.session.get(TABLES_KEY, [])
}

/* 手工下单返回的数据 */
export const setHandTableStorage = (query) => {
  storage.session.set(HANDTABLE_KEY, query)
  return query
}
export const loadHandTableStorage = () => {
  return storage.session.get(HANDTABLE_KEY, [])
}

/* 礼品包 */
export const setPackagesStorage = (query) => {
  storage.session.set(PACKAGES_KEY, query)
  return query
}
export const loadPackagesStorage = () => {
  return storage.session.get(PACKAGES_KEY, [])
}

/* 礼品包添加过的状态 */
export const setAddedPackageStorage = (query) => {
  storage.set(ADDEDPACKAGE_KEY, query)
  return query
}
export const loadAddedPackageStorage = () => {
  return storage.get(ADDEDPACKAGE_KEY, [])
}

/* 物流价格列表 */
export const setLogisticListStorage = (query) => {
  storage.session.set(LOGISTICLIST_KEY, query)
  return query
}
export const loadLogisticListStorage = () => {
  return storage.session.get(LOGISTICLIST_KEY, [])
}

/* 常用礼品包 */
export const setCommonPackageStorage = (query) => {
  storage.session.set(COMMONPACKAGE_KEY, query)
  return query
}
export const loadCommonPackageStorage = () => {
  return storage.session.get(COMMONPACKAGE_KEY, [])
}

/* 常用LOGO */
export const setLogoInfoStorage = (query) => {
  storage.session.set(LOGOINFO_KEY, query)
  return query
}
export const loadLogoInfoStorage = () => {
  return storage.session.get(LOGOINFO_KEY, [])
}
